#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# :CREATED: [2018-04-26 Thu 21:34]
# :AUTHOR: zb
from flask import Flask
from models import create_all
from flask_bootstrap import Bootstrap
from routes.server.server import main as server_routes
from routes.index import main as index_routes
from routes.address import main as address_routes
from routes.cloudoss.alive_check import main as alive_check_routes
from routes.myrowk_scheduler import main as my_scheduler
from routes.myrowk_scheduler import scheduler, Config
from routes.cloudoss.nmon import main as nmon_routes



app = Flask(__name__)
bootstrap = Bootstrap(app)
app.secret_key = 'haha'

create_all()

app.register_blueprint(index_routes)
app.register_blueprint(server_routes, url_prefix='/server')
app.register_blueprint(address_routes, url_prefix='/address')
app.register_blueprint(alive_check_routes, url_prefix='/aliveCheck')
app.register_blueprint(my_scheduler, url_prefix='/scheduler')
app.register_blueprint(nmon_routes, url_prefix='/nmon')


app.config.from_object(Config())
scheduler.init_app(app)
scheduler.start()

if __name__ == '__main__':
    config = dict(
        debug=True,
        host='0.0.0.0',
        port=5000,
    )
    app.run(**config)
    # HTTPS://114.119.11.201:61234
    # HTTP://118.201.203.89
